{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Dynamic Process: Robustness to the Share of Updating Voters (with CW) (C.2)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:45.469003Z", "start_time": "2021-02-09T13:45:39.185427Z" } }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd\n", "from matplotlib import pyplot as plt\n", "from poisson_approval import *" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:45.479931Z", "start_time": "2021-02-09T13:45:45.474307Z" } }, "outputs": [], "source": [ "N_SAMPLES = 10000\n", "N_MAX_EPISODES = 1000" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:45.519824Z", "start_time": "2021-02-09T13:45:45.485914Z" } }, "outputs": [], "source": [ "update_ratios = {\n", " '1': 1,\n", " '0.5': 0.5,\n", " 'one_over_log_log_t_plus_fourteen': one_over_log_log_t_plus_fourteen,\n", " 'one_over_log_t_plus_one': one_over_log_t_plus_one,\n", " 'one_over_sqrt_t': one_over_sqrt_t,\n", " 'one_over_t': one_over_t, \n", "}" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:45.534344Z", "start_time": "2021-02-09T13:45:45.523812Z" } }, "outputs": [], "source": [ "rand_profile = RandConditional(\n", " RandProfileHistogramUniform(n_bins=1), \n", " test=is_condorcet, n_trials_max=None\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Condorcet consistency:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2021-02-09T13:45:50.392888Z", "start_time": "2021-02-09T13:45:45.538641Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
ApprovalPluralityAnti-plurality
Share of updating voters
10.9978380.66700.102871
0.50.9995520.66970.267519
one_over_log_log_t_plus_fourteen0.9997490.67300.257903
one_over_log_t_plus_one0.9999080.66280.496961
one_over_sqrt_t0.9998000.66970.570528
one_over_t0.9997000.65730.603082
\n", "
" ], "text/plain": [ " Approval Plurality Anti-plurality\n", "Share of updating voters \n", "1 0.997838 0.6670 0.102871\n", "0.5 0.999552 0.6697 0.267519\n", "one_over_log_log_t_plus_fourteen 0.999749 0.6730 0.257903\n", "one_over_log_t_plus_one 0.999908 0.6628 0.496961\n", "one_over_sqrt_t 0.999800 0.6697 0.570528\n", "one_over_t 0.999700 0.6573 0.603082" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "table_cond = pd.DataFrame()\n", "table_cond.index.name = 'Share of updating voters'\n", "for update_ratio_name, update_ratio in update_ratios.items():\n", " results = monte_carlo_fictitious_play(\n", " factory=rand_profile,\n", " n_samples=N_SAMPLES,\n", " n_max_episodes=N_MAX_EPISODES,\n", " voting_rules=VOTING_RULES,\n", " init='random_tau',\n", " ballot_update_ratio=update_ratio,\n", " monte_carlo_settings=[\n", " MCS_FREQUENCY_CW_WINS,\n", " ],\n", " file_save='sav/ballot_update_%s_with_CW.sav' % update_ratio_name,\n", " )\n", " for voting_rule in VOTING_RULES:\n", " table_cond.loc[update_ratio_name, voting_rule] = float(results[voting_rule]['mean_frequency_cw_wins'])\n", "table_cond" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.7" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": true, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": false, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 4 }